<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<TPOJ.Model.Problem>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Volume <%= Html.Encode(ViewData["VolumeId"]) %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Volume <%= Html.Encode(ViewData["VolumeId"]) %></h2>

    <table>
        <tr>
        <% if (Request.IsAuthenticated) { %>
        <th></th>
        <% } %>
            <th>
                ID
            </th>
            <th>
                Title
            </th>
            <th>
                Ratio(AC/submit)
            </th>
            <th>
                Date
            </th>
         <% if(User.Identity.IsAuthenticated && User.IsInRole("Administrators")) { %>
            <th>
                Edit
            </th>
         <% } %>
        </tr>
        <% IList<int> solvedIds = new List<int>();
            IList<int> triedIds = new List<int>(); %>
        <% if (Request.IsAuthenticated) { solvedIds = (IList<int>)ViewData["SolvedIds"]; triedIds = (IList<int>)ViewData["TriedIds"]; } %>
    <% foreach (var item in Model) { %>
        <tr>
            <% if (Request.IsAuthenticated) { %>
        <td>
            <% if (solvedIds.Contains(item.UniqueID)) { %>
                <img src="..\..\Content\Solved.png" alt="solved"/>
            <% } else {
                   if (triedIds.Contains(item.UniqueID)) { %>
                <img src="..\..\Content\Tried.png" alt="Tried" />
                <% } %>
            <% } %>
        </td>
        <% } %>
            <td>
                <%= Html.Encode(item.UniqueID) %>
            </td>
            <td>
                <%= Html.ActionLink(item.Title, "Details", "Problem", new { id = item.UniqueID }, new { target = "_blank" })%>
            </td>
            <td>
                <%= Html.Encode(TPOJ.Web.Utils.ComputeRatio(item.Solved,item.Summit) + "% (" + item.Solved + "/" + item.Summit + ")") %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:g}", item.Date)) %>
            </td>
            <% if(User.Identity.IsAuthenticated && User.IsInRole("Administrators")) { %>
            <td>
                <%= Html.ActionLink("Edit", "Edit", new { id = item.UniqueID }, new { target = "_blank" }) %>
            </td>
         <% } %>
        </tr>
    
    <% } %>

    </table>

</asp:Content>

